-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: shebangs #3922
fix: shebangs #3922
Conversation
Build failure is unrelated (Python format). Requesting a maintainer to trigger it again. |
@brandonkal I restarted CI but it failed at the same point, so I don't think it's unrelated. Can you run format.py locally? |
My bad. The fact python was calling Prettier threw me off. It should pass now. |
@piscisaureus Note that it is still preferrable to not have a semicolon there. Some shells will print "./catj.ts: 2: ./catj.ts: //: Permission denied" before executing the script. |
CC @nayeemrmn I remember you were updating shebangs some time ago. Can you take a look? |
Yeah, the |
#!/usr/bin/env -S deno run --reload --allow-run | ||
#!/bin/sh | ||
":" //; exec /usr/bin/env deno run --reload --allow-run "$0" "$@" | ||
.charAt(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't parse this.. what is happening here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The first line tells unix to parse as a shell script line by line.
- The
:
command which is quoted to be valid JavaScript is the "Do nothing beyond expanding arguments and performing redirections." Its only argument is//
which is a valid path. - Then we start a new shell statement after the
;
inside the JavaScript comment. exec
replaces the shell process with deno passing the desired deno arguments, the script file "$0" and any arguments the user provides "$@"- The
.charAt(0);
line is required so that Prettier doesn't insert a semicolon after the ":" JavaScript statement. So instead JavaScript executes":".charAt(0);
which is basically a no-op.
Thanks for the patch but sorry this is too weird. We need another solution. |
@ry It is weird but it is the only current solution that is portable especially as In most environments only one argument can be passed to a program by env. Then the shebang could look like this: #!/usr/bin/env deno -x
// deno run --reload --allow-run "$0" "$@" |
I'd rather change how we parse args so we can support all types of env |
@ry So you would say the "-x" solution is good? |
@brandonkal anything is better than exposing the hack in this patch : ) |
Okay. I'll look to add |
Which platforms does this work on? The Linux limitation is one interpreter I tried this and it calls |
Oh yes of course. So it looks like this will remain unsolved. |
The existing shebangs were not portable to Linux (which has no -S option).
This fix enables the shebangs to function in a more portable way.